const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const json5 = require('json5');

module.exports = {
  mode: 'development',
  entry: './src/index.ts',
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.json5$/i,
        type: 'json',
        parser: {
          parse: json5.parse,
        },
      },
    ]
  },
  plugins: [
    new CleanWebpackPlugin()
  ],
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
  },
  output: {
    filename: 'index.js',
    path: path.resolve(__dirname, 'dist'),
    library: {
      root: 'flowStyle',
      amd: 'flow-style',
      commonjs: 'flow-style'
    },
    libraryTarget: 'umd'
  }
}